
<%@taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>


	<script>
		$(document).ready(function(){	
			$("#loginForm").validate({
				rules: {
					loginName: {
						required : true
					},
					password: {
						required: true
					}
				}
			});
		});
		
		function loginFormSubmitComplete(responce){
			if($.trim(responce) == 'success'){
				top.location.href='secure/showDashboard.do';
			} else {
				$('#login-form').html(responce);
			}
		}
	</script>	

   	<c:url value="/login.do" var="loginUrl" />      
	<form:form name="loginForm" id="loginForm" action="${loginUrl}" method="post" commandName="user">
		<table>
			<tr class="row">
		  		<td class="label">&nbsp;</td>
		  	    <td class="input-field" colspan="2"><form:errors path="" cssClass="error" element="div" /></td>
			</tr>
			<tr class="row">
		  		<td class="label"><spring:message code="login.label.username"/></td>
		  	    <td class="input-field"><form:input path="loginName" cssClass="input-full-width" /></td>
		  	    <td><form:errors path="loginName" cssClass="error"/></td>
			</tr>
		   	<tr class="row">
		   	    <td class="label"><spring:message code="login.label.password"/></td>
		   	    <td class="input-field"><form:password path="password" cssClass="input-full-width" /></td>
		  	    <td><form:errors path="password" cssClass="error"/></td>
		 	</tr>
		 	<tr class="row">
		 	   	<td class="label"> &nbsp; </td>
		   		<td class="input-field">
		   			<sj:submit id="loginFormSubmit" key="login.button.login" validate="true" submitComplete="loginFormSubmitComplete" />
		   			<input type="reset" value="<spring:message code='login.button.reset' />"/>			   			
		   		</td>
		   		<td> &nbsp; </td>
		   	</tr>
		</table>     
	</form:form>
